package com.scalpel.web.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by scalpel on 2017/1/5.
 */
public class WebLocal {

    /**
     * 获取当前线程request
     */
    private static  ThreadLocal<HttpServletRequest> requestThreadLocal = new ThreadLocal<HttpServletRequest>();

    /**
     * 获取当前线程reponse
     */
    private static  ThreadLocal<HttpServletResponse> responseThreadLocal = new ThreadLocal<HttpServletResponse>();

    public static void setRequest(HttpServletRequest request)
    {
        requestThreadLocal.set(request);
    }

    public static HttpServletRequest getRequest()
    {
        return requestThreadLocal.get();
    }

    public static void setResponse(HttpServletResponse response)
    {
        responseThreadLocal.set(response);
    }

    public static HttpServletResponse getResponse()
    {
        return responseThreadLocal.get();
    }
}
